import http from '@/utils/request.js'
// import { getUser } from '@/utils/storage.js'
/**
 * 用户登录请求
 */
export const reqUserLogin = (mobile, code) => {
  return http({
    method: 'post',
    url: '/mp/v1_0/authorizations',
    data: {
      mobile,
      code
    }
  })
}

/**
 * 获取用户的身份信息
*/
export const reqGetUserInfo = () => {
  // const userInfo = JSON.parse(localStorage.getItem('userInfo')) || {}
  // const userInfo = getUser()
  // console.log(userInfo)
  return http({
    method: 'get',
    url: '/mp/v1_0/user/profile'
    // 这里不再需要携带请求头了，会在axios请求拦截器自动添加上
  })
}
/**
 * 更改用户信息
 * @param {*} data
 */
export const reqChangeUserInfo = (data) => {
  return http({
    method: 'patch',
    url: '/mp/v1_0/user/profile',
    data
  })
}

export const reqLoadImg = (formData) => {
  return http({
    method: 'patch',
    url: '/mp/v1_0/user/photo',
    data: formData
  })
}
